package algorithm;

import java.util.Arrays;
        // 选择排序
public class Test2 {
    public static void main(String[] args) {
        int[] arr = {5, 2, 3, 4};
        for (int i = 0; i < arr.length - 1; i++) {
            // i = 0, 1, 2                      [2, 3, 4, 5]
            // i = 0                             3
            // i = 1                             2
            // i = 2                             1
            for (int j = i +1; j < arr.length; j++) {
                if(arr[i] > arr[j]){
                    int temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
